/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - resource
// Copyright( c) 2014.  All Rights Reserved
//
// File:		AETextureFormatProviderI.h
// Author:		Gianluca Belardelli
// Date:		02/10/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AETEXTUREFORMATPROVIDERI_H_
#define _AETEXTUREFORMATPROVIDERI_H_

/// \brief
///   Interface to add support for custom texture formats to the engine and to vForge.
///
/// By installing a custom format provider, plugins can hook into the texture loading pipeline and load custom texture file formats.
/// The engine tries to load textures via the installed providers before it loads textures through the default path.
/// Installed providers not only load custom textures inside the runtime, they also show up in the file browser dialog inside vForge.
/// Providers can be installed via VTextureManager::RegisterFormatProvider (accessible through Vision::TextureManager.GetManager().RegisterFormatProvider(...)).
/// A good place to do that is at plugin initialization time (function OnInitEnginePlugin).
class AETextureFormatProviderI
{
// Methods
public:
	virtual ~AETextureFormatProviderI( void )
	{
	}

	/// \brief
	///   Returns a list of supported file extensions for this provider. 
	///
	/// \param iListCount
	///   This reference must receive the number of list entries in the returned array (typically this is 1)
	///
	/// \return 
	///   List of strings with iListCount entries. Each string represents a file extension (without '.' and case-insensitive) that can be loaded by this provider. 
	virtual const char **GetSupportedFileExtensions( AEINT32 &nListCount ) = 0;

	/// \brief
	///   Creates a texture instance for the passed filename
	///
	/// \param szFilename
	///   Filename of the texture to load. The filename has an extension that is returned by GetSupportedFileExtensions.
	///
	/// \param iFlags
	///   Loading flags. Passed through from VTextureManager::Load2DTextureFromFile. It is a reference so it can be changed inside the function
	///
	/// \return 
	///   A new instance of VTextureObject. This can be of a class derived from it for custom VTextureObject::Reload/VTextureObject::Unload implementations. 
	///
	virtual AETexture *CreateTexture( const char *lpFilename, AEINT32 &nFlags ) = 0;

	/// \brief
	///   Optional: Create a system memory preview of the passed texture filename. This function is only used inside the editor, so the relevant code can be ifdef'd with WIN32.
	///
	/// \param szFilename
	///   Filename to load
	///
	/// \param destImg
	///   Reference that should receive the image at full size.
	///
	/// \param bAlphaMap
	///   if true, the alpha channel of this texture is to be loaded
	///
	/// \return 
	///   bool bResult: true if the image has been generated successfully
	///
	/*virtual AEBOOL32 CreatePreview( const char *lpFilename, AEImage &imgDestImg, AEBOOL32 bAlphaMap )
	{
		return 0;
	}*/

	/// \brief
	///   Returns a list of subtexture names for texture files which consist of multiple separate textures
	///
	/// If the texture format provider supports container formats where a single texture file contains multiple texture images,
	/// this method should be implemented to allow these subtextures to have separate names.
	///
	/// \param szFilename
	///   Filename to load
	///
	/// \param destNames
	///   List of names for the subtextures
	///
	/// \param destNiceNames
	///   List of nice names for the subtextures (e.g. as more descriptive nice names in UIs)
	///
	/// \return 
	///   bool bResult: true if the texture file contains subtextures, otherwise false.
	///
	virtual AEBOOL32 GetSubTextureNames( const char *lpFilename, char **lpDestNames, char **lpDestNiceNames )
	{
		return 0;
	}
};

#endif // _AETEXTUREFORMATPROVIDERI_H_
